lisp codeEn 2016-11-21 14:30:04
Prime number
(defun prime-number-p (number)
  "Returns true if the number is prime; otherwise returns false"
  (let ((counter 2)); the second prime number
    (cond
      ;; special case
      ;; the definition of prime number
      ((equal number 1)
       t)
      ;; apply the  prime number definition
      (t
       (loop
      (when  (equal counter number)
        (return t))
      (if (= (mod number counter) 0)
          (return nil))
      (incf counter))))))

#lisp
También te puede interesar
lisp codeEn 2022-07-13 13:12:00